package com.lwj.liwanjia.adapter.indent;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.view.activity.myindent.JdUnorederDetailActivity;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/21.
 */

public class UnOrderAdapter extends SuperBaseAdapter<String> {
    private List<String> list;//商城
    private Context mContext;
    private boolean flag;//用来判断是否是详情 true代表是

    public UnOrderAdapter(Context context, List<String> data, boolean flag) {
        super(context, data);
        list = new ArrayList<>();
        list.add("1");
        this.flag = flag;
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, String item, int position) {
        holder.setText(R.id.tv_state, "待接单");
        holder.setVisible(R.id.ll_fukuan, false)//隐藏待付款按钮
                .setVisible(R.id.rl_indent_btn, true);//显示取消订单
        if (item.equals("10") || item.equals("11") || item.equals("12")) {//帮我送,买，取
            if (item.equals("10")) {//帮我送
                holder.setText(R.id.tv_bangwo, "帮我送");
                holder.setImageResource(R.id.iv_address1, R.mipmap.fahuodizhi)
                        .setImageResource(R.id.iv_address2, R.mipmap.quhuodizhi);
            } else if (item.equals("11")) {//帮我取
                holder.setText(R.id.tv_bangwo, "帮我取");
                holder.setImageResource(R.id.iv_address1, R.mipmap.quhuodizhi)
                        .setImageResource(R.id.iv_address2, R.mipmap.shouhuodizhi);
            } else {
                holder.setText(R.id.tv_bangwo, "帮我买");
                holder.setImageResource(R.id.iv_address1, R.mipmap.purchaseadd)
                        .setImageResource(R.id.iv_address2, R.mipmap.songhuodizhi);
            }
        } else if (item.equals("1")) {//旅游
            holder.setVisible(R.id.rl_daoyou, false);//取消导游费用栏
        } else if (item.equals("5")) {//酒店外卖
            SuperRecyclerView rlvJiudian = holder.getView(R.id.rlv_jiudian);
            LinearLayoutManager manager = new LinearLayoutManager(mContext);
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            rlvJiudian.setLayoutManager(manager);
            rlvJiudian.setRefreshEnabled(false);
            rlvJiudian.setLoadMoreEnabled(false);
            JiudianAdapter jiudianAdapter = new JiudianAdapter(mContext, list);
            rlvJiudian.setAdapter(jiudianAdapter);
            jiudianAdapter.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(View view, Object item, int position) {
                    Intent intent = new Intent(mContext, JdUnorederDetailActivity.class);
                    intent.putExtra("type","待接单");
                    mContext.startActivity(intent);
                }
            });
        } else if (item.equals("3") || item.equals("4")) {//宾馆
            if (item.equals("3")) {
                holder.setImageResource(R.id.iv_shangjia_icon, R.mipmap.binguantouxiang)
                        .setVisible(R.id.rl_binguan2, true)
                        .setText(R.id.tv_shangjia_name, "速8宾馆")
                        .setText(R.id.tv_binguan_name, "高级双人床")
                        .setText(R.id.tv_binguan_price, "￥30.0元/天");
            } else {//看房
                holder.setImageResource(R.id.iv_shangjia_icon, R.mipmap.touxiang_1)
                        .setVisible(R.id.rl_binguan2, false)
                        .setText(R.id.tv_shangjia_name, "JJFJFJFJF")
                        .setText(R.id.tv_binguan_name, "龙湾区海滨房")
                        .setText(R.id.tv_binguan_price, "￥3000.0元/月")
                        .setText(R.id.tv_binguan_jiesao, "四周环绕着大海，每天清晨都会感受到一缕阳光。");
            }
        } else if (item.equals("0")) {//搬家
            holder.setImageResource(R.id.iv_shangjia_icon, R.mipmap.touxiang_2)
                    .setText(R.id.tv_shangjia_name, "KFFFSDDD");
        } else if (item.equals("6") || item.equals("7")) {//滴滴
            if (item.equals("7")) {//预约今天
                holder.setVisible(R.id.tv_yuyue, false);
            } else {//预约明天
                holder.setVisible(R.id.tv_yuyue, true);
            }
            holder.setImageResource(R.id.iv_shangjia_icon, R.mipmap.touxiang)
                    .setText(R.id.tv_shangjia_name, "GGHFHJFHF");
        } else if (item.equals("8") || item.equals("9")) {//包间选择-预约酒店
            if (item.equals("8")) {
                holder.setVisible(R.id.tv_red_circle, true)//红点显示
                        .setVisible(R.id.indent_btn, false);//底部按钮隐藏
            } else {
                holder.setVisible(R.id.tv_red_circle, false)//红点不显示
                        .setVisible(R.id.indent_btn, true);//底部按钮显示
            }
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, String item) {
        if (item.equals("0")) {//搬家
            return R.layout.unpaid_banjia_item;
        } else if (item.equals("1")) {//旅游
            return R.layout.unpaid_lvyou_item;
        } else if (item.equals("2")) {//导游服务
            return R.layout.unorder_daoyou_item;
        } else if (item.equals("3") || item.equals("4")) {//宾馆,看房
            return R.layout.unpaid_binguan_item;
        } else if (item.equals("5")) {//酒店和外卖
            return R.layout.unpaid_jiudian_item;
        } else if (item.equals("6") || item.equals("7")) {//司机，专车，滴滴
            return R.layout.unorder_car_item;
        } else if (item.equals("8") || item.equals("9")) {//酒店包间
            return R.layout.unorder_jiudian_item;
        } else if (item.equals("10") || item.equals("11") || item.equals("12")) {//帮我送,买，取
            return R.layout.unpaid_bangwosong_item;
        } else if (item.equals("13")) {//寄快递
            return R.layout.unpaid_kuaidi_item;
        }
        return 0;
    }
}
